﻿@model List<LeadMaster.Models.LeadStat>

<div>
<table class="listtable contactstable" cellspacing="0" cellpadding="0" style="width: 600px;" id="statlist">
<thead>
    <tr>
    <th class="tableheader" style="width: 200px;">Title</th>
    <th class="tableheader">Display Order</th>
    <th class="tableheader">Questionnaire Order</th>
    <th class="tableheader"></th>
    <th class="tableheader"></th>
    </tr>
</thead>
@foreach (var item in Model)
{
    <tr>
    <td><label class="selectstatsection" data-statid="@(item.LeadStatID)" style="cursor: pointer; color: #333333;">@item.Title</label></td>
    <td><label>@item.DisplayOrder</label></td>
    <td><label>@item.QuestionOrder</label></td>
    <td><input type="button" value="Questions" class="leadstat" data-statid="@(item.LeadStatID)" /></td>
    <td><img src="~/Images/delete.ico" style="width: 20px; height: 20px" class="deletestatsectionquestion" data-statsectionquestionid="@(item.LeadStatID)"/></td>
    </tr>
}
</table>
</div>

<div id="statquestions">
</div>



<script type="text/javascript">
$(document).ready(function () {
    $("#statquestions").dialog(
    {
        autoOpen: false,
        width: 1200,
        open: function () { $(".ui-dialog").css("box-shadow", "#000 5px 5px 5px"); },
        position: ['middle', 20],
        modal: true,
        dialogClass: 'notitle',
        buttons: {

            cancel: function () {
                $(this).dialog("close");
            }
        }
    });

    $(".leadstat").click(function () {
        $("#statquestions").dialog("open");
        $('#statquestions').html('<div style="text-align: center;"><div><img src="@Url.Content("~/Images/ajaxspinner_large.gif")" alt="Loading..." style="margin: 20px;" /></div><div>Loading...</div></div>');
        var contactURL = '@(Url.Action("ShowStatQuestions", "LeadBuilder"))/?id=' + $(this).data("statid");
        $('#statquestions').load(contactURL);
    });

    $(".selectstatsection").click(function () {
        $("#EditLeadStat").dialog("open");
        $('#EditLeadStat').html('<div style="text-align: center;"><div><img src="@Url.Content("~/Images/ajaxspinner_large.gif")" alt="Loading..." style="margin: 20px;" /></div><div>Loading...</div></div>');
        var contactURL='@(Url.Action("EditLeadStat", "LeadBuilder"))/?id=' + $(this).data("statid");
        $('#EditLeadStat').load(contactURL);
    });

    $(".deletestatsectionquestion").click(function () {
        var ans = confirm("Are you sure you wish to delete this question ?")
        if (ans == true) {
            var contactURL = '@(Url.Action("DeleteStatSectionQuestion", "LeadBuilder"))/?id=' + $(this).data("statsectionquestionid");
            $('#ShowLeadStat').load(contactURL);
        }
    });
});
</script>